from kivy.app import App
from kivy.lang import Builder
from kivy.properties import NumericProperty, StringProperty
from kivy.uix.button import Button

from goblinoid.profile.profilemodal import ProfileModal

Builder.load_file('goblinoid/feed/kv/actor.kv')


class Actor(Button):
    index = NumericProperty()
    actor = StringProperty()

    def open_profile_modal(self):
        activity = self.get_activity()
        profile = activity.actor
        profile_modal = ProfileModal(profile)
        profile_modal.open()

    def get_activity(self):
        return App.get_running_app().pump_service.inbox[self.index]
